package cn.buk.tms.dto;

import cn.buk.tms.entity.base.Airline;
import org.springframework.beans.BeanUtils;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * 航空公司基础信息DTO
 * @author yfdai
 */
public class AirlinesDto {

    private int id;

    @NotNull
    @Size(min = 2, max = 2)
    private String twoCode;

    private String threeCode;

    private String nickName;

    private String englishNickName;

    @NotNull
    private String name;

    private String englishName;

    public static AirlinesDto createBy(Airline info) {
        AirlinesDto dto = new AirlinesDto();

        BeanUtils.copyProperties(info, dto);
        dto.setEnglishName(info.getEnName());
        dto.setEnglishNickName(info.getEnNickName());

        return dto;
    }

    public static Airline convertTo(AirlinesDto dto) {
        Airline obj = new Airline();

        BeanUtils.copyProperties(dto, obj);
        obj.setEnName(dto.getEnglishName());
        obj.setEnNickName(dto.getEnglishNickName());

        return obj;
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTwoCode() {
        return twoCode;
    }

    public void setTwoCode(String twoCode) {
        this.twoCode = twoCode.trim().toUpperCase();
    }

    public String getThreeCode() {
        return threeCode;
    }

    public void setThreeCode(String threeCode) {
        this.threeCode = threeCode.trim().toUpperCase();
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName.trim();
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name.trim();
    }

    public String getEnglishName() {
        return englishName;
    }

    public void setEnglishName(String englishName) {
        this.englishName = englishName;
    }

    public String getEnglishNickName() {
        return englishNickName;
    }

    public void setEnglishNickName(String englishNickName) {
        this.englishNickName = englishNickName;
    }
}
